class Solution
{
public:
    int singleNumber(vector<int>& nums)
    {

        int ret = 0;

        for (int i = 0; i < 32; i++)
        {
            int num = 0;
            for (int j = 0; j < nums.size(); j++) num += 1 & (nums[j] >> i);
            num %= 3;
            ret |= num << i;
        }

        return ret;
    }
};